home *** CD-ROM | disk | FTP | other *** search
- Path: news.sover.net!news
- From: sstryker@sover.net (Stew Stryker)
- Newsgroups: comp.lang.c++
- Subject: Re: Does VAX C++ support templates?
- Date: Sun, 17 Mar 1996 17:59:10 -0400
- Organization: Southern Vermont Network
- Message-ID: <19960317215910.sstryker@sover.net>
- References: <19960317181747.sstryker@sover.net>
- NNTP-Posting-Host: pm0a15.wrj.sover.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-NewsReader: Emissary News v1.01.007, by Wollongong Inc.
-
- It seems that VAX C++ doesn't support templates, at least not in the form
- from the (non-VAX) examples I'm working from.
-
- I tried the following:
-
-
- #include <iostream.h>
- const int DefaultSize = 10;
-
- template <class T>
- class Array
- {
- public:
- // constructors
- Array(int itsSize = DefaultSize);
- Array(const Array &rhs);
- ~Array() { delete [] pType; }
-
- // Operators
- Array& operator=(const Array&);
- T& operator[](int offSet) { return pType[offSet]; }
-
- // Accessors
- int getSize() { return itsSize; }
-
- private:
- T *pType;
- int itsSize;
- };
-
- main()
- {
- Array<int> theNumbers;
-
- for (int i = 0; i < theNumbers.getSize(); i++)
- theNumbers[i] = i * 2;
-
- for (i = 0; i < theNumbers.getSize(); i++)
- cout << "[" << i << "]: " << theNumbers[i] << ".\n";
-
- cout << "Done." << endl;
- }
-
-
- And the compiler complained about the constructor:
-
- Array(const Array &rhs);
-
- saying that Array's type (the second instance) wasn't specified. I did the
- same at the other places in the definition where Array was specified. I
- tried inserting <T> in those place, which compiled. But then the linker
- said that the symbol Array was undefined.
-
- Suggestions?
-
- Thanks,
-
- Stew
-